package com.taotao.sso.service;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.abel533.mapper.Mapper;
import com.taotao.common.service.RedisService;
import com.taotao.sso.mapper.UserMapper;
import com.taotao.sso.pojo.User;

@Service
public class UserService {
	

	
	@Autowired
	private RedisService redisService;
	
	
	private static final ObjectMapper MAPPER=new ObjectMapper();
	

	



	

	
	/**
	 * 用户登录
	 * @param user
	 * @return
	 * @throws JsonProcessingException 
	 */
	public String login(User user) throws JsonProcessingException {
		
		
		String ticket="TICKET"+System.currentTimeMillis()+user.getUsername();
		
		if(redisService.get(user.getUsername())==null){
			redisService.set(user.getUsername(), ticket, 3600);
		};
		

		
		ticket=redisService.get(user.getUsername());
	
		
		return ticket;
	}

	

	
}
